package com.example.androidlearning2200.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.example.androidlearning2200.LoginActivity;
import com.example.androidlearning2200.MConstant;

/**
 * 收到广播后，打开登陆界面
 */
public class LoginReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(MConstant.ACTION_OPEN_LOGIN)) {
            String username = intent.getExtras().getString("username");
            String password = intent.getExtras().getString("password");
            Log.d("UUU", "用户名：" + username + ",密码：" + password);
            // 收到我关心的广播，执行打开登陆界面的操作
            Intent intent2Login = new Intent(context, LoginActivity.class);
            intent2Login.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
            context.startActivity(intent2Login);
        }
    }
}
